<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/inc/sessionCheck.jsp" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display"%>
<%@ taglib uri="/WEB-INF/config/tld/fmt.tld" prefix="fmt"%>
<%@ taglib uri="http://ssh.org/selects" prefix="ssh"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
	String applicationPath = basePath + "/" + "application";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title></title>
		<link href="<%=path%>/css/jinmu_style.css" rel="stylesheet" type="text/css" />
		<script language="javascript" src="<%=path%>/js/util.js"></script>
	</head>
	<html:form styleId="attachmentForm" action="/uploadAttachment.do?method=uploadAttachment" method="post" enctype="multipart/form-data">
	<input type="hidden" name="type" id="type" value="${attachmentForm.type}"/>
	<input type="hidden" name="fid" id="fid" value="${attachmentForm.fid}"/>
	<input type="hidden" name="bak1" id="bak1" value="${attachmentForm.bak1}"/>
	<input type="hidden" name="bak2" id="bak2" value="${attachmentForm.bak2}"/>
	<body>
	             
				
				   <table cellspacing="0" cellpadding="0" width="98%" align="center"  border="0" class="kuang2 margb5">
					  <tr>
					     <td colspan="3" class="bkuang bgcolor2 zi13b padl5"><ssh:select propertyName="type" pid="FILE_TYPE" type="3" defaultName="${attachmentForm.type}" />附件资料</td>
			
					  </tr>
					  <tr>
					    <td align="center" width="30%" class="bgcolor3 brkuang zi13b">附件名称</td>
					    <td align="center" width="40%" class="bgcolor3 brkuang zi13b">上传时间</td>
					    <td align="center" width="30%" class="bgcolor3 bkuang zi13b">操作</td>
					  </tr>
					  <logic:iterate name="attachmentList" id="attachment">
					  	  <tr>
						    <td align="center" class="brkuang zi13"><a href="#" onclick="download('${attachment.id}')">${attachment.filename}</a></td>
						    <td align="center" class="brkuang zi13"><bean:write name="attachment" property="inputtime" format="yyyy-MM-dd" /></td>
						    <td align="center" class="bkuang padl5 zi13"><a href="#" onclick="delAttachment('${attachment.id}','${attachment.fid}','${attachment.type}')">删除</a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="download('${attachment.id}')">下载</a></td>
					      </tr>
					  </logic:iterate>
					</table>
				
				<!-- 
	              <table cellspacing="0" cellpadding="0" width="98%" align="center"  border="0" class="kuang2 margb5" >
				  <tr>
				    <td width="30%" align="right" class="brkuang zi13">附件：</td>
				    <td width="70%" align="left" class="bkuang pad2 zi13">
				        <html:file property="formFile" size="30"></html:file>  
				    <input type="button" onclick="upload();" name="Submit" value="上传" class="buttonbg"></td>
				  </tr>
				  <tr>
				    <td align="right" class="rkuang zi13">上传要求：</td>
				    <td align="left" class="padl5 zi13">允许上传多个附件（单个附件大小不能超过10MB）。 </td>
				  </tr>
				</table>
 -->
		
			<br/>
		</html:form>	
		
</body>
</html>
<script>

function upload(){

  var projectNo = '${attachmentForm.bak1}';
  $('bak1').value = projectNo;
  document.forms['attachmentForm'].action="uploadAttachment.do?method=uploadAttachment";
  document.forms['attachmentForm'].submit();

}
window.onload = pageInit;
function pageInit(){
    <logic:present name="message"> 
        alert("<bean:write name="message"/>");
	</logic:present>
}
function download(id){
    window.location.href = "downAttachment.do?method=downAttachment&id=" + id;
}

function delAttachment(id,fid,type){
    window.location.href = "deleteAttachment.do?method=deleteAttachment&id=" + id + "&fid=" + fid + "&type=" + type;
}

</script>